package org.example.priority;

import static cn.hutool.core.lang.Console.log;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title : aa
 * @Description: :
 * @author: libo@juzishuke.com
 * @date: 2023/10/24 15:24
 * @Version:1.0
 */
public class ThreadPriority {

    public static void main(String[] args) {
        Map<String, Integer> countMap = new HashMap<>();
        Thread t1 = new Thread(() -> {
            while (true) {
                countMap.put("t1", countMap.getOrDefault("t1", 0)+1);
                log(countMap);
            }
        });
        t1.setPriority(1);

        Thread t2 = new Thread(() -> {
            while (true) {
                countMap.put("t2", countMap.getOrDefault("t2", 0)+1);
                log(countMap);
            }
        });
        t2.setPriority(10);
        t1.start();
        t2.start();
    }
}
